package com.snatch.snatchmgr.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.snatch.common.constant.SnatchConstant;
import com.snatch.snatchmgr.service.ReceieveInnerDataService;
import com.snatch.snatchmgr.vo.WebSnatchInfo;
@Controller
@RequestMapping("/node")
public class NodeController {
	@Autowired
	private ReceieveInnerDataService receieveInnerDataService;
	
	@RequestMapping("start")
	public String startNode(String nodeCode,String webCode,final RedirectAttributes redirectAttributes){
		receieveInnerDataService.nodeRun(nodeCode,webCode);
		redirectAttributes.addAttribute("webCode", webCode);
		return "redirect:/node/findItem";
	}
	
	
	@RequestMapping("findItem")
	public String findItem(Model model,String webCode){
		if(null == webCode){
			webCode = SnatchConstant.THIRD_SYSTEM_HG_VALUE;
		}
		List<WebSnatchInfo> websnatchifos  = receieveInnerDataService.findWebSnatchInfos(webCode);
		model.addAttribute("websnatchifos", websnatchifos);
		model.addAttribute("webCode", webCode);
		return "node/nodeItems";
	}
}
